/** Project : Sticky Notes Plus */
/** Author  : Sainagakishore Srikantham */
/** Email   : ssn.kishore@gmail.com */

/** File    : StickyNotesPlus.cpp */
/** Purpose : This file contains the definition for the class CStickyNotesPlus which is the main class of the project */

#include "StickyNotesPlus.h"
#include "StickyNotesUIMgr.h"
#include "StickyNotesLoginMgr.h"
#include "StickyNotesDataMgr.h"

CStickyNotesPlus* CStickyNotesPlus::self = NULL;

/** Returns the singleton instance of the class */
CStickyNotesPlus* CStickyNotesPlus::GetInstance()
{
    if(self == NULL)
    {
        self = new CStickyNotesPlus();
    }
    return self;
}

/** Constructor of the class */
CStickyNotesPlus::CStickyNotesPlus()
{
    iStickyLoginMgr = CStickyNotesLoginMgr::GetInstance();
    iStickyUIMgr = new CStickyNotesUIMgr();
    iStickyDataMgr = new CStickyNotesDataMgr();
}

/** Destructor of the class */
CStickyNotesPlus::~CStickyNotesPlus()
{
    StopApp();

    if(iStickyDataMgr)
    {
        delete iStickyDataMgr;
        iStickyDataMgr = NULL;
    }
    if(iStickyLoginMgr)
    {
        delete iStickyLoginMgr;
        iStickyLoginMgr = NULL;
    }
    if(iStickyUIMgr)
    {
        delete iStickyUIMgr;
        iStickyUIMgr = NULL;
    }
}

/** Starts the application */
void CStickyNotesPlus::StartApp()
{
    iStickyUIMgr->RegisterActions();
    iStickyUIMgr->hide();
    iStickyDataMgr->ReloadNotes();
}

/** Stop the application */
void CStickyNotesPlus::StopApp()
{
    iStickyUIMgr->close();
}

/** Returns the data manager instance */
CStickyNotesDataMgr* CStickyNotesPlus::GetDataMgr()
{
    return iStickyDataMgr;
}

/** Returns the login manager instance */
CStickyNotesLoginMgr* CStickyNotesPlus::GetLoginMgr()
{
    return iStickyLoginMgr;
}

/** Returns the UI manager instance */
CStickyNotesUIMgr* CStickyNotesPlus::GetUIMgr()
{
    return iStickyUIMgr;
}
